# test python
print(list(range(3, 6)))
args = [3, 6]
print(list(range(*args)))


# lambda
def make_incrementor(n):
    return lambda x: x + n

f = make_incrementor(34)
print(f(2))  # 36
print(f(5))  # 39

def f(ham: str, eggs: str='eggs') -> str:
    print('annotations: ', f.__annotations__)
    print('arguments: ', ham, eggs)
    return ham + ' and ' + eggs
f('spam')

empty = ()
singleton = 'hello',
print(len(empty))
print(len(singleton))

# zip function
questions = ['huhx', 'liuling', 'linux']
answers = ['name', 'lover', 'nickname']
for q, a in zip(questions, answers):
    print('What is your {0}?  It is {1}.'.format(q, a))

# exceptions
x = input('Please enter a number')
try:
    int(x)
except ValueError as error:
    print('try again', error)
    raise
finally:
    print('clean up4f')

try:
    raise Exception('spam', 'eggs')
except Exception as inst:
    print(type(inst))
    print(inst.args)
    print(inst)
finally:
    print('clean up')